package com.ysd.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.impl.ChanPinFenLeiDaoImpl;
import com.ysd.dao.impl.ChanPinXinXiDaoImpl;
import com.ysd.entity.ChanPinFenLei;
import com.ysd.entity.ChanPinXinXi;

public class ProductsDetailServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		ChanPinFenLeiDaoImpl cpDao=new ChanPinFenLeiDaoImpl();
		List<ChanPinFenLei> cpList= cpDao.getChanPinFenLeiList();
		request.setAttribute("cpList", cpList);
		int pId=0;
		if(request.getParameter("pId")!=null && !request.getParameter("pId").equals("")) {
			pId=Integer.parseInt(request.getParameter("pId"));
		}
		
		ChanPinXinXiDaoImpl pDao=new ChanPinXinXiDaoImpl();
		List<ChanPinXinXi> cpxx =pDao.getCPXXcPId(pId);
		request.setAttribute("cpxx", cpxx);
		System.out.println(cpxx);
		request.getRequestDispatcher("productdetails.jsp").forward(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
